package org.example.all;
import com.google.common.base.Splitter;
import org.apache.commons.lang3.StringUtils;
import org.openjdk.jmh.util.HashMultiset;
import org.openjdk.jol.util.Multiset;

import javax.imageio.ImageIO;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.file.Files;
import java.util.Spliterators;
import java.util.concurrent.TimeUnit;
import java.util.regex.Matcher;
import java.util.regex.Pattern;


public class App implements Cloneable{
    private static final Pattern patten = Pattern.compile("SQL");
    private static final Pattern sqlPa = Pattern.compile("select|join|where|on|and|or|group by|order by|\\n");


    public static void main(String[] args ) throws Exception {

//        TimeUnit.SECONDS.sleep(4);
//        String s = "SQLdwdqwqddSQLdwdqwqddSQLdwdqwqddSQLdwdqwqddSQLdwdqwqdd";
//
//        long start = System.currentTimeMillis();
//        for (int i = 0; i < 10000000; i++) {
//            String[] sqls = s.split("SQL");
//        }
//        System.out.println(System.currentTimeMillis() - start);
//
//
//        start = System.currentTimeMillis();
//        for (int i = 0; i < 10000000; i++) {
//            String[] split = patten.split(s);
//        }
//        System.out.println(System.currentTimeMillis() - start);
//
//        start = System.currentTimeMillis();
//        for (int i = 0; i < 10000000; i++) {
//            String[] split = StringUtils.split(s, "SQL");
//        }
//        System.out.println(System.currentTimeMillis() - start);
//        Multiset<String> wordOccurrences = HashMultiset.create(
//                Splitter.on(CharMatcher.WHITESPACE)
//                        .trimResults()
//                        .omitEmptyStrings()
//                        .split(Files.asCharSource(file, Charsets.UTF_8).read()));
        String sql ="SeLECT id AS categoryid, categoryid AS categoryid1, COUNT(bugid) AS allnum\n" +
                "    , SUM(a.BUGKIND = '客户需求') AS cdnum\n" +
                "    , COUNT(DISTINCT a.COMPANY) AS ccnum\n" +
                "    , SUM(POW(3, (a.BUGKIND = '客户需求') + (6 - priority2) - 2) * ((a.BUGKIND = '客户需求') + 6 - priority2 > 1)) AS pri\n" +
                "FROM (\n" +
                "    SELECT bug_id, bugid, priority, categoryid, bugkind\n" +
                "        , company, bugstatus, ifnull(priority, 3) AS priority2\n" +
                "        , c.id, name\n" +
                "    FROM fr_t_p_demand t1\n" +
                "        LEFT JOIN fr_t_system1 t2 ON t1.bugid = t2.FR_SYSTEM_ID\n" +
                "        LEFT JOIN fr_t_p_category c ON concat(\"\", \"\", categoryid, \"\", \"\") REGEXP concat(\"\", \"\", c.id, \"\", \"\")\n" +
                "    WHERE (bugkind = '客户需求'\n" +
                "            OR bugkind = '一般需求')\n" +
                "        AND categoryid IS NOT NULL\n" +
                "        AND length(categoryid) > 0\n" +
                "        AND (t2.bugstatus NOT IN (\n" +
                "                '创建者验收',\n" +
                "                '创建者补充',\n" +
                "                '被否决',\n" +
                "                '验收完成',\n" +
                "                '已解决',\n" +
                "                '关闭',\n" +
                "                'BUG已解决'\n" +
                "            )\n" +
                "            OR t2.bugstatus IS NULL)\n" +
                "        AND categoryid LIKE concat(LPAD(6, 3, 0), '%')\n" +
                "        AND categoryid != LPAD(6, 3, 0)\n" +
                ") a\n" +
                "GROUP BY id\n" +
                "ORDER BY pri";
//        String aaa = "aaorder by";
//        System.out.println(aaa.indexOf("order by"));
        System.out.println((char) 0 + "1");
    }


    protected native App t();


    @Override
    protected Object clone() throws CloneNotSupportedException {
        return super.clone();
    }
}
